package org.marsdonne.commons.oss;

import org.marsdonne.commons.SnowFlakeCore;

import java.io.InputStream;

public interface ObjectStorable {
    class UploadResult {
        private String md5;
        private String url;

        public UploadResult(String md5, String url) {
            this.md5 = md5;
            this.url = url;
        }

        public String getMd5() {
            return md5;
        }

        public String getUrl() {
            return url;
        }
    }

    SnowFlakeCore SNOW_FLAKE_CORE = new SnowFlakeCore();

    UploadResult upload(final String space, final String category, final String name, long contentLength, String contentType, final InputStream inputStream);

    default UploadResult upload(final String space, final String category, final long contentLength, String contentType, final InputStream inputStream) {
        return upload(space, category, Long.toString(SNOW_FLAKE_CORE.nextId()), contentLength, contentType, inputStream);
    }

    default UploadResult upload(Space space, Category category, final long contentLength, final String contentType, final InputStream inputStream) {
        return upload(space.value, category.value, contentLength, contentType, inputStream);
    }
}
